package com.firewolf.rabbitmq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import utils.ConnectionUtils;

public class Sender {

	private final static String QUEUE_NAME = "simple_queue";

	public static void main(String[] args) throws Exception {

		Connection connection = ConnectionUtils.getMQConnection();

		Channel channel = connection.createChannel(); // 创建通道

		channel.queueDeclare(QUEUE_NAME, false, false, false, null); // 声明要使用的队列

		String message = "Hello World!"; // 要发送的消息

		// 发布消息
		channel.basicPublish("", QUEUE_NAME, null, message.getBytes("UTF-8")); // 发布消息

		channel.close();// 关闭通道
		connection.close(); // 关闭连接
	}
}
